package com.yida.system.api.factory;

import com.yida.common.core.domain.R;
import com.yida.system.api.RemoteDictDataService;
import com.yida.system.api.domain.SysDictData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 文件服务降级处理
 *
 * @author yida
 */
@Component
public class RemoteDictDataFallbackFactory implements FallbackFactory<RemoteDictDataService> {
	private static final Logger log = LoggerFactory.getLogger(RemoteDictDataFallbackFactory.class);

	@Override
	public RemoteDictDataService create(Throwable throwable) {
		log.error("字典服务调用失败:{}", throwable.getMessage());
		return new RemoteDictDataService() {
			@Override
			public R<List<SysDictData>> dictType(String dictType, String source) {
				return R.fail("字典查询失败:" + throwable.getMessage());
			}
		};
	}
}
